package com.hoas.quickstart.threads.chapter01.chapter01_2_8;

public class LoginServlet {

    private static String usernameRef;

    private static String passwordRef;

    /**
     * 加上synchronized可演示线程安全情况
     * 加上后，b线程进入了等待状态
     */
    public static void doPost(String username, String password) {

        try {

            usernameRef = username;

            if (username.equals("a")) {
                Thread.sleep(5000);
            }

            passwordRef = password;
            System.out.printf("username=%s, password=%s\n", usernameRef, passwordRef);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
}
